package bairui.international.console.web.controller.user.user;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import com.lianjing.sh.project.config.web.Project_Config_Web_PageTemplate;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.module.context.ModuleContext;
import com.lianjing.sh.spring.web.controller.enhance.navigations.context.NavigationContext;
import com.lianjing.sh.spring.web.controller.enhance.tab.TabContext;

import bairui.international.console.web.controller.branch.branch.staff.C_BranchCompanyStaff_ShowQRImg_ShowImg;
import bairui.international.console.web.controller.user.Tab_User;
import bairui.international.model.domain.jpa.TB_BranchCompanyStaff;
import bairui.international.model.domain.jpa.TB_User;
import bairui.international.model.status.State_User;
import bairui.international.service.Service_User;

/**
 *
 * 详情
 *
 * @generated
 * 
 * @see STest_C_User_User_Detail_DetailAccess 测试
 *
 */
@Controller
public class C_User_User_Detail_DetailAccess
 extends SC_User_User_Detail_DetailAccess 
{
	
	@Autowired private Service_User service_User;
	
	/**
	 * 访问详情页面
	 */
	@SuppressWarnings("serial")
	@Action(DetailAccess.class)
	@GetMapping(DetailAccess.RequestMappingValue)
	public ModelAndView detailAccess(
		ModelMap map, HttpServletRequest request, TabContext tabContext,
		NavigationContext navigationContext, ModuleContext moduleContext, 
		@PathVariable(name=DetailAccess.PathVariableName.Id) long id
	) throws Exception {
		TB_User bean = service_User.findById(id);
		State_User state_User = bean.getState();
		/* Tab */
		Tab_User.tab(tabContext, id, bean.getType());
		/* 模块 */
		moduleContext
			.addModule(module_BaseInfo.module(
					new Module_BaseInfo_OutputModel(bean),
					new C_User_User_UpSaler_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public bairui.international.model.status.State_User getState_User() { return state_User; }
					},
					new C_User_User_UpAgent_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public bairui.international.model.status.State_User getState_User() { return state_User; }
					},
					new C_User_User_StrategyPartner_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public bairui.international.model.status.State_User getState_User() { return state_User; }
					}, 
					new C_User_User_Freeze_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public bairui.international.model.status.State_User getState_User() { return state_User; }
					}, 
					new C_User_User_UnFreeze_Submit.Submit.Operate(){
						@Override public Object getId() { return id; }
						@Override public bairui.international.model.status.State_User getState_User() { return state_User; }
					}
				));
		TB_BranchCompanyStaff sender = bean.getSender();
		if(null != sender){
			moduleContext
				.addModule(this.module_SenderInfo.module(
						new Module_SenderInfo_OutputModel(sender){
							@Override protected void assign_before() {
								this
									.setDimensionalUrl(
										new C_BranchCompanyStaff_ShowQRImg_ShowImg.ShowImg.Operate() {
											@Override public Object getId() {
												return sender.getId();
											}
											@Override public Object getBranchId() {
												return sender.getBranchCompany().getId();
											}
										}.getUrl()
									);
							}
							@Override public String assignAvatarUrl() {
								System.out.println(sender.getUser().getAvatarUrl() + "==getAvatarUrl===");
								return sender.getUser().getAvatarUrl();
							}
							@Override public String assignNickName() {
								return sender.getUser().getNickName();
							}
							@Override public String assignRealName() {
								return sender.getUser().getRealName();
							}
							@Override public String assignPhone() {
								return sender.getUser().getPhone();
							}
							@Override public java.util.Date assignCreateTime() {
								return sender.getUser().getCreateTime();
							}
							@Override public State_User assignState() {
								return sender.getUser().getState();
							}							
						}
					));
		}
		//
		return Project_Config_Web_PageTemplate.Admin_Common(request);
	}
	

}
